package com.sc.test.socketDemo.serverClient;

import java.io.IOException;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;

/**
 * @version 1.0
 * @Author: 许啸林 使用 Socket 对象创建一个客户端连接 向本机 9999端口发送 hello,wold
 * @Date: 2021/6/6 15:17
 */
public class ClientDemo {

    public static void main(String[] args) throws IOException {

        Socket socket = new Socket(InetAddress.getLocalHost(), 9999);
        OutputStream outputStream = socket.getOutputStream();
        String sendInfo = "hello,world";
        outputStream.write(sendInfo.getBytes());
        System.out.println("向服务端发送信息:" + sendInfo);
        outputStream.close();
        socket.close();
    }
}
